﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;


namespace DALLifeIt
{
    public class Linq3tierDALBase
    {
        private DataContext _innerDataContext = null;
        protected DataContext innerDataContext
        {
            get
            {
                string ConnectionString = Setting.Default.Settings;
                if (_innerDataContext == null)
                    _innerDataContext = new DataContext(ConnectionString);
                return _innerDataContext;
            }
        }

        //Metodo genérico para traer tablas
        protected Table<T> GetTables<T>() where T : class
        {
            return innerDataContext.GetTable<T>();
        }

        public virtual void Save()
        {
            innerDataContext.SubmitChanges();
        }
    }
}
